<?php
header("content-type:text/html;charset=utf-8");
$db=@new mysqli("localhost","root","123123","xbs_bbs");
if($db->connect_errno){
    echo "错误信息为：".$db->connect_error;
}
$db->query("set names utf8");



if($db->errno){
    echo "错误信息是：".$db->error;
}

$sql="select * from stu t1 inner join class t2 on t2.id=t1.cid inner join stu_ext t3 on t3.sid=t1.id inner join kaoshi t4 on t4.sid=t1.id inner join kemu t5 on t5.id=t4.kid";
$b=$db->query($sql);

$t=$b->fetch_assoc();
$arrkey=array_keys($t);
//while($res=$b->fetch_assoc()){
//    $arrb[]=array_keys()
//}
//var_dump($arrkey);exit();
$b=$db->query($sql);
$arrv;
while($res=$b->fetch_assoc()){
    $arrv[]=$res;
}


$lenz=count($arrkey);
$len=count($arrv);
echo "<table style='width: 1000px;height: 700px;margin: 0 auto;text-align: center'>";
for($k=0;$k<$lenz;$k++){
    echo "<th style='background-color: palegoldenrod'>".$arrkey[$k]."</th>";
}
for($i=0;$i<$len;$i++){

    echo "<tr>";
    foreach($arrv[$i] as $v){
        echo "<td style='background-color: #f1f1f1'>";

        echo $v;
        echo "</td>";
    }


    echo "</tr>";
}
echo "</table>";